#include "stdafx.h"
#include "Interface.h"

static unsigned int SIZE = 8;

//===========================================================================
int _tmain(
    int      argc,
    _TCHAR * argv[]
) {

#ifdef _DEBUG
    _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif

    const unsigned int players = 2;
    IBoard * board = CreateBoard( SIZE, EPT_WHITE, EPT_BLACK );
    IPlayer * player[ players ] = {
        CreatePlayer(   EPT_WHITE, board ),
        CreatePlayerAI( EPT_BLACK, board )
    };
    
    bool gameover = false;
    while( true ) {
        for( unsigned int i = 0; i < players; i++ ) {
            
            for( unsigned int j = 0; j < SIZE; j++ )
                std::cout << "===";
            std::cout << std::endl;
            
            board->Show();
            if( !player[ i ]->Move() )
                gameover = true;
            else
                gameover = board->IsGameOver();
            
            if( gameover )
                break;
        }

        if( gameover )
            break;
    }
    std::cout << "game over!" << std::endl;

    board->Release();
    board = NULL;
    for( unsigned int i = 0; i < players; i++ ) {
        player[ i ]->Release();
        player[ i ] = NULL;
    }


#ifdef _DEBUG
    _CrtDumpMemoryLeaks();
#endif    
    
    getchar();
    return 0;
}